<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../common/taglibs.jsp"%>
<%--<%@include file="../common/header_easyui.jsp" %>--%>
<script type="text/javascript">
    $(document).ready(function() {
        $("#uploader").plupload({
            runtimes : 'flash',
            url : '${ctx}/docAttachments/upload.do',
            max_file_size : '10mb',
            maxCount: 10,
            chunk_size : '10gb',
            unique_names : true,
            multipart_params :{"doc" : '${param.docId}'},

            // Resize images on clientside if we can
//            resize : {width : 320, height : 240, quality : 90},

            // Specify what files to browse for
            filters : [
                {title : "图片文件", extensions : "jpg,jpeg,gif,png,bmp"}
                ,{title : "压缩文件", extensions : "zip,jar,rar,tar,gz"}
                ,{title : "Office文件", extensions : "doc,docx,rtf,xls,xlsx,pdf,ppt,pptx"}
            ],

            // Flash settings
            flash_swf_url : '<c:url value="/js/jquery/plupload/plupload.flash.swf"/>',

            // Post init events, bound after the internal events
            init : {
                Refresh: function(up) {
                    // Called when upload shim is moved
                    // alert('[Refresh]');
                }

                <%--,StateChanged: function(up) {--%>
                    <%--if(up.state == plupload.STOPPED) {--%>
                        <%--// 获取上传文件列表--%>
                        <%--$("#fsUploadProgress").load("<c:url value="/docAttachments/afterUpload.do"/>?" + Math.random());--%>

<%--//                        $("#uploader").css('display','none');--%>
                        <%--$("#tips").css('display','none');--%>
                    <%--}--%>
                <%--}--%>
            }
        });

        // Client side form validation
        $('form').submit(function(e) {
//            var uploader = $('#uploader').pluploadQueue();
            var uploader = $('#uploader').plupload('getUploader');

            // Files in queue upload them first
            if (uploader.files.length > 0) {
                // When all files are uploaded submit form
                uploader.bind('StateChanged', function() {
                    if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                        $('#uploadForm').submit();
                    }
                });

                uploader.start();
            } else {
                alert('请至少选择一个文件进行上传.');
            }

            return false;
        });
    });
</script>
<div id="fileUploadDiv" style="width: 606px">
    <form id="uploadForm">
    <div id="uploader" style="width: 606px">
        <%--<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>--%>
    </div>
    </form>
    <div id="tips"><b>提示：</b>文件大小不要超过10MB</div>
</div>